﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data.Common;

namespace DbLayer
{
    class DbSqlConnection
    {

        private static DbSqlConnection _instance = null;

        private string _connectionString = @"Data Source=balder.ucn.dk;Initial Catalog=dm76_5;Persist Security Info=True;MultipleActiveResultSets=True;User ID=DM76_5;Password=MaaGodt";
        private SqlConnection _connection;
        
        private DbSqlConnection()
        {
            _connection = new SqlConnection();
            _connection.ConnectionString = _connectionString;
            _connection.Open();
        }

        public static DbSqlConnection Instance
        {
            get
            {

                if (_instance == null)
                {
                    _instance = new DbSqlConnection();
                }

                return _instance;

            }
        }

        public SqlConnection Connection
        {
            get { return _connection; }
        }

        public void PrintConnection()
        {
            Console.WriteLine(_connection.State.ToString());
            Console.WriteLine(_connection.Database.ToString());
        }

    }
}